export { }
class Person {
    //默认public
    public name: string
    private age: number
    protected gender: boolean
    constructor(name: string, age: number, gender: boolean) {
        this.name = name
        this.age = age
        this.gender = gender

    }
    sayHi(): void {
        console.log(`I am${this.name} 今年${this.age}岁了`)
    }
}


class Student extends Person {
    public clazz: string
    private constructor(name: string, age: number, gender: boolean, clazz: string) {
        super(name, age, gender)
        this.clazz = clazz
        //可访问gender
        console.log(this.gender)
    }

    static create(name: string, age: number, gender: boolean, clazz: string) {
        return new Student(name, age, gender, clazz)
    }
}
const p1 = new Person("Tom", 1, false)
console.log(p1.name)
//console.log(p1.age) //报错

const s1 = Student.create("Tom", 1, false, "class1")
